/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package flames.view;

import com.sun.awt.AWTUtilities;
import flames.utils.SwingUtils;

import java.awt.Color;
import java.awt.Point;

/**
 * @author 10373
 */
public class AboutFrame extends javax.swing.JFrame {

    private Point pressedPoint;
    public final Color NORMAL_COLOR = new Color(132, 132, 132);   // #848484
    public final Color ACTIVE_COLOR = new Color(242, 135, 24);    // #f28718

    /**
     * Creates new form NewJFrame
     */
    private AboutFrame() {
        this.setUndecorated(true);     // 只有在窗体不可显示时才调用此方法
        this.setResizable(false);   // 设置不可以重置窗口大小
        this.getContentPane().setBackground(Color.white);   // 设置背景颜色
        this.setSize(1230, 810);
        this.setLocationRelativeTo(null);   // 设置居中
        initComponents();
        SwingUtils.beautifyButtonToTransparent(existButton);    // 美化按钮的公共方法
        AWTUtilities.setWindowOpacity(this, 0.99f);  // 设置透明度
        AWTUtilities.setWindowOpaque(this, false);  // 设置通透
        head.setOpaque(true);    // 设置透明
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ShadowLayeredPane = new DropShadowPanel(15);
        loadingPane = new javax.swing.JLayeredPane();
        head = new javax.swing.JLabel();
        logo = new javax.swing.JLabel();
        existButton = new javax.swing.JButton();
        aboutTitle = new javax.swing.JLabel();
        aboutSubTitle = new javax.swing.JLabel();
        aboutLabel1 = new javax.swing.JLabel();
        aboutLabel2 = new javax.swing.JLabel();
        aboutTermsLabel = new javax.swing.JLabel();
        aboutPrivacyLabel = new javax.swing.JLabel();
        BKG = new javax.swing.JLabel();
        confirmImg = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                formMouseDragged(evt);
            }
        });
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mainFrameMousePressed(evt);
            }
        });

        ShadowLayeredPane.setBackground(new java.awt.Color(255, 255, 255));

        loadingPane.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        head.setBackground(new java.awt.Color(248, 249, 249));
        loadingPane.setLayer(head, javax.swing.JLayeredPane.PALETTE_LAYER);
        loadingPane.add(head, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 550, 50));

        logo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_Flames.png"))); // NOI18N
        loadingPane.setLayer(logo, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(logo, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, -2, 60, 50));

        existButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_close.png"))); // NOI18N
        existButton.setAlignmentY(0.0F);
        existButton.setFocusPainted(false);
        existButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                existButtonMouseEntered(evt);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
                existButtonMouseExited(evt);
            }
        });
        existButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                existButtonActionPerformed(evt);
            }
        });
        loadingPane.setLayer(existButton, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(existButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 0, 70, 50));

        aboutTitle.setFont(new java.awt.Font("微软雅黑", 1, 24)); // NOI18N
        aboutTitle.setForeground(new java.awt.Color(51, 51, 51));
        aboutTitle.setText("关于火苗");
        loadingPane.setLayer(aboutTitle, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(aboutTitle, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 0, 120, 50));

        aboutSubTitle.setFont(new java.awt.Font("微软雅黑", 1, 27)); // NOI18N
        aboutSubTitle.setForeground(new java.awt.Color(51, 51, 51));
        aboutSubTitle.setText("火苗安全软件");
        loadingPane.setLayer(aboutSubTitle, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(aboutSubTitle, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 50, 180, 50));

        aboutLabel1.setFont(new java.awt.Font("微软雅黑", 0, 16)); // NOI18N
        aboutLabel1.setForeground(new java.awt.Color(51, 51, 51));
        aboutLabel1.setText("珠海火苗安全科技有限公司版权所有");
        loadingPane.setLayer(aboutLabel1, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(aboutLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 220, 280, 40));

        aboutLabel2.setFont(new java.awt.Font("微软雅黑", 0, 16)); // NOI18N
        aboutLabel2.setForeground(new java.awt.Color(51, 51, 51));
        aboutLabel2.setText("Copyright @ 2012-2022 Flames.All rights reserved.");
        loadingPane.setLayer(aboutLabel2, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(aboutLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 250, 420, 40));

        aboutTermsLabel.setFont(new java.awt.Font("微软雅黑", 0, 16)); // NOI18N
        aboutTermsLabel.setForeground(new java.awt.Color(51, 51, 51));
        aboutTermsLabel.setText("许可协议");
        loadingPane.setLayer(aboutTermsLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(aboutTermsLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 280, 70, 30));

        aboutPrivacyLabel.setFont(new java.awt.Font("微软雅黑", 0, 16)); // NOI18N
        aboutPrivacyLabel.setForeground(new java.awt.Color(51, 51, 51));
        aboutPrivacyLabel.setText("隐私政策");
        loadingPane.setLayer(aboutPrivacyLabel, javax.swing.JLayeredPane.MODAL_LAYER);
        loadingPane.add(aboutPrivacyLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 280, 70, 30));

        BKG.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/SecurityToolsPane/Security_Tools_BKG.png"))); // NOI18N
        BKG.setToolTipText("");
        BKG.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                BKGMouseDragged(evt);
            }
        });
        BKG.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                BKGMousePressed(evt);
            }
        });
        loadingPane.add(BKG, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 1, 550, 350));

        confirmImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/update/flamesLogo.png"))); // NOI18N
        loadingPane.setLayer(confirmImg, javax.swing.JLayeredPane.PALETTE_LAYER);
        loadingPane.add(confirmImg, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 90, 180, 130));

        ShadowLayeredPane.setLayer(loadingPane, javax.swing.JLayeredPane.PALETTE_LAYER);

        javax.swing.GroupLayout ShadowLayeredPaneLayout = new javax.swing.GroupLayout(ShadowLayeredPane);
        ShadowLayeredPane.setLayout(ShadowLayeredPaneLayout);
        ShadowLayeredPaneLayout.setHorizontalGroup(
                ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(loadingPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        ShadowLayeredPaneLayout.setVerticalGroup(
                ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(loadingPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 347, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addComponent(ShadowLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addComponent(ShadowLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //切换退出按钮的样式
    private void toggleExistButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(Color.red);
        }
    }

    // 切换普通按钮的样式
    private void toggleNormalButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(Color.gray);
        }
    }

    // 切换主要按钮的样式
    private void togglePrimaryButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(ACTIVE_COLOR);
        }
    }


    private void mainFrameMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainFrameMousePressed
        pressedPoint = evt.getPoint();// 记录鼠标坐标
    }//GEN-LAST:event_mainFrameMousePressed

    private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged
        Point point = evt.getPoint();// 获取当前坐标
        Point locationPoint = getLocation();// 获取窗体坐标
        int x = locationPoint.x + point.x - pressedPoint.x;// 计算移动后的新坐标
        int y = locationPoint.y + point.y - pressedPoint.y;
        setLocation(x, y);// 改变窗体位置,（按钮可以使用边界布局,也可以使用绝对布局）

    }//GEN-LAST:event_formMouseDragged

    // 点击退出按钮, 触发此方法
    private void existButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_existButtonActionPerformed
        toggleExistButtonStyle(existButton);    // 切换退出按钮成正常的
        this.dispose();     // 销毁这个窗口的资源
    }//GEN-LAST:event_existButtonActionPerformed

    // 切换样式
    private void existButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_existButtonMouseEntered
        toggleExistButtonStyle(existButton);
    }//GEN-LAST:event_existButtonMouseEntered

    // 切换样式
    private void existButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_existButtonMouseExited
        toggleExistButtonStyle(existButton);
    }//GEN-LAST:event_existButtonMouseExited

    // 供拖拽窗口使用
    private void BKGMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BKGMousePressed
        mainFrameMousePressed(evt);
    }//GEN-LAST:event_BKGMousePressed

    // 供拖拽窗口使用
    private void BKGMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BKGMouseDragged
        formMouseDragged(evt);
    }//GEN-LAST:event_BKGMouseDragged



    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                AboutFrame.runInstance();
            }
        });
    }

    public static AboutFrame aboutFrame;

    public static void runInstance() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (aboutFrame == null) {
                    aboutFrame = new AboutFrame();
                }
                aboutFrame.setVisible(true);

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel BKG;
    private javax.swing.JLayeredPane ShadowLayeredPane;
    private javax.swing.JLabel aboutLabel1;
    private javax.swing.JLabel aboutLabel2;
    private javax.swing.JLabel aboutPrivacyLabel;
    private javax.swing.JLabel aboutSubTitle;
    private javax.swing.JLabel aboutTermsLabel;
    private javax.swing.JLabel aboutTitle;
    private javax.swing.JLabel confirmImg;
    private javax.swing.JButton existButton;
    private javax.swing.JLabel head;
    private javax.swing.JLayeredPane loadingPane;
    private javax.swing.JLabel logo;
    // End of variables declaration//GEN-END:variables
}


